You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

jest-util

Package Overview
Dependencies
Maintainers
7
Versions
260
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

jest-util


Version published
Weekly downloads
44M
decreased by-19.08%
Maintainers
7
Created
Weekly downloads
 

Package description

What is jest-util?

The jest-util package provides utility functions for Jest, a popular JavaScript testing framework. It includes a variety of helpers and tools that are used internally by Jest but can also be useful for developers working with or extending Jest tests.

What are jest-util's main functionalities?

Console Replacement

This feature allows for the creation of a custom console that buffers all logs. This is useful for controlling and testing console output during test runs.

const { BufferedConsole } = require('jest-util');
const customConsole = new BufferedConsole();
customConsole.log('Hello, this is a buffered log.');

Error Formatting

This function formats execution errors for display in Jest's output, providing a standardized view of test errors, including stack traces.

const { formatExecError } = require('jest-util');
const error = new Error('Test error');
const config = {rootDir: '/path/to/project', testMatch: []};
console.log(formatExecError(error, config, {noStackTrace: false}, undefined, true));

Test Path Normalization

This utility normalizes file paths for glob matching, which is particularly useful on Windows where path separators differ.

const { replacePathSepForGlob } = require('jest-util');
const path = 'path\to\test\file.js';
console.log(replacePathSepForGlob(path));

Other packages similar to jest-util

Changelog

Source

25.5.0

Features

  • [@jest/globals] New package so Jest's globals can be explicitly imported (#9801)
  • [jest-core] Show coverage of sources related to tests in changed files (#9769)
  • [jest-runtime] Populate require.cache (#9841)

Fixes

  • [*] Use graceful-fs directly in every package instead of relying on fs being monkey patched (#9443)
  • [expect] Prints the Symbol name into the error message with a custom asymmetric matcher (#9888)
  • [jest-circus, jest-jasmine2] Support older version of jest-runtime (#9903 & #9842)
  • [@jest/environment] Make sure not to reference Jest types (#9875)
  • [jest-message-util] Code frame printing should respect --noStackTrace flag (#9866)
  • [jest-runtime] Support importing CJS from ESM using import statements (#9850)
  • [jest-runtime] Support importing parallel dynamic imports (#9858)
  • [jest-transform] Improve source map handling when instrumenting transformed code (#9811)

Chore & Maintenance

  • [docs] Add an example for mocking non-default export class

Performance

  • [jest-resolve] Update resolve to a version using native realpath, which is faster than the default JS implementation (#9872)
  • [jest-resolve] Pass custom cached realpath function to resolve (#9873)
  • [jest-runtime] Add teardown method to clear any caches when tests complete (#9906)
  • [jest-runtime] Do not pass files required internally through transformation when loading them (#9900)
  • [jest-runtime] Use Maps instead of object literals as cache holders (#9901)

FAQs

Package last updated on 28 Apr 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc